﻿using Autofac;
using Infrastructure.Bases;
using Infrastructure.Tools;
using System.Reflection;

namespace WorldSystem.Api.Configs
{
    public class AutofacModuleConfig:Autofac.Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            // 批量注册用例服务
            Assembly appServicesDll = Assembly.Load("AppServices");
            builder.RegisterTypes(appServicesDll.DefinedTypes.Where(p=>p.Name.EndsWith("AppService")).ToArray());
            //Assembly services = Assembly.Load("Services");
            //builder.RegisterAssemblyTypes(interfaces, services).AsImplementedInterfaces();

            // 注册自定义工具服务
            builder.RegisterType<TodayTestTool>();

            //注册泛型仓储服务
            builder.RegisterGeneric(typeof(BaseRepository<>));
            builder.RegisterGeneric(typeof(BaseAppService<>));

        }
    }
}
